Conditions | 3 |
Paths | 10245 |
Total Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /** global: VRS */ |
||
3 | VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) { |
||
|
|||
4 | if(VRS.renderPropertyHandlers) { |
||
5 | VRS.renderPropertyHandlers[VRS.RenderProperty.OperatorFlag] = new VRS.RenderPropertyHandler({ |
||
6 | property: VRS.RenderProperty.OperatorFlag, |
||
7 | surfaces: VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow, |
||
8 | headingKey: 'ListOperatorFlag', |
||
9 | labelKey: 'OperatorFlag', |
||
10 | sortableField: VRS.AircraftListSortableField.OperatorIcao, |
||
11 | headingAlignment: VRS.Alignment.Centre, |
||
12 | suppressLabelCallback: function() { return true; }, |
||
13 | fixedWidth: function() { return VRS.globalOptions.aircraftOperatorFlagSize.width.toString() + 'px'; }, |
||
14 | hasChangedCallback: function(aircraft) { return aircraft.operatorIcao.chg || aircraft.icao.chg || aircraft.registration.chg || aircraft.manufacturer.chg; }, |
||
15 | renderCallback: function(aircraft) { return customFormatOperatorIcaoImageHtmlAircraft(aircraft); }, |
||
16 | tooltipChangedCallback: function(aircraft) { return aircraft.operatorIcao.chg || aircraft.operator.chg; }, |
||
17 | tooltipCallback: function(aircraft) { return aircraft.formatOperatorIcaoAndName(); } |
||
18 | }); |
||
19 | |||
20 | VRS.renderPropertyHandlers[VRS.RenderProperty.SilhouetteAndOpFlag] = new VRS.RenderPropertyHandler({ |
||
21 | property: VRS.RenderProperty.SilhouetteAndOpFlag, |
||
22 | surfaces: VRS.RenderSurface.List, |
||
23 | headingKey: 'ListModelSilhouetteAndOpFlag', |
||
24 | labelKey: 'SilhouetteAndOpFlag', |
||
25 | headingAlignment: VRS.Alignment.Centre, |
||
26 | sortableField: VRS.AircraftListSortableField.OperatorIcao, |
||
27 | fixedWidth: function() { return Math.max(VRS.globalOptions.aircraftSilhouetteSize.width, VRS.globalOptions.aircraftOperatorFlagSize.width).toString() + 'px'; }, |
||
28 | // Changed the following line to include manufacturer |
||
29 | hasChangedCallback: function(aircraft) { return aircraft.modelIcao.chg || aircraft.operatorIcao.chg || aircraft.registration.chg || aircraft.manufacturer.chg; }, |
||
30 | // And this line to include a call to the custom HTML |
||
31 | renderCallback: function(aircraft) { return aircraft.formatModelIcaoImageHtml() + customFormatOperatorIcaoImageHtmlAircraft(aircraft); }, |
||
32 | tooltipChangedCallback: function(aircraft) { return aircraft.model.chg || aircraft.modelIcao.chg || aircraft.countEngines.chg || aircraft.engineType.chg || aircraft.species.chg || aircraft.wakeTurbulenceCat.chg || aircraft.operatorIcao.chg || aircraft.operator.chg; }, |
||
33 | tooltipCallback: function(aircraft) { |
||
34 | var silhouetteTooltip = aircraft.formatModelIcaoNameAndDetail(); |
||
35 | var opFlagTooltip = aircraft.formatOperatorIcaoAndName(); |
||
36 | return silhouetteTooltip && opFlagTooltip ? silhouetteTooltip + '. ' + opFlagTooltip : silhouetteTooltip ? silhouetteTooltip : opFlagTooltip; |
||
37 | } |
||
38 | }); |
||
39 | } |
||
40 | |||
41 | if(VRS.reportPropertyHandlers) { |
||
42 | VRS.reportPropertyHandlers[VRS.ReportAircraftProperty.OperatorFlag] = new VRS.ReportPropertyHandler({ |
||
43 | property: VRS.ReportAircraftProperty.OperatorFlag, |
||
44 | surfaces: VRS.ReportSurface.List + VRS.ReportSurface.DetailHead, |
||
45 | headingKey: 'ListOperatorFlag', |
||
46 | labelKey: 'OperatorFlag', |
||
47 | headingAlignment: VRS.Alignment.Centre, |
||
48 | fixedWidth: function() { return VRS.globalOptions.aircraftOperatorFlagSize.width.toString() + 'px'; }, |
||
49 | hasValue: function(/** VRS_JSON_REPORT_AIRCRAFT */ json) { return !!json.opFlag || !!json.icao || !!json.reg || !!json.manufacturer; }, |
||
50 | renderCallback: function(/** VRS_JSON_REPORT_AIRCRAFT */ json) { return customFormatOperatorIcaoImageHtml(json.manufacturer, json.opFlag, json.reg, json.icao); }, |
||
51 | tooltipCallback: function(/** VRS_JSON_REPORT_AIRCRAFT */ json) { return VRS.format.operatorIcaoAndName(json.owner, json.opFlag); } |
||
52 | }); |
||
53 | } |
||
54 | }); |
||
55 | } |
||
92 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.